package com.best.oasis.settlement.common.entity.security;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;

import com.best.oasis.settlement.common.entity.base.BaseBizEntity;

/**
 * 权限组，为了方便用户授权而添加此类。
 * <p>
 * 实现的功能：
 * <ul>
 * <li>1、权限组和权限的关系是一对多</li>
 * <li>2、把权限组授权给某一个用户，则用户拥有该组中的所有权限</li>
 * </ul>
 * 
 * @author bl00252
 * 
 */
@Entity
@Table(name = "ST_ROLEGROUP")
public class RoleGroup extends BaseBizEntity implements Serializable {

	private static final long serialVersionUID = -3528494658062181073L;
	//@Id
	//@GeneratedValue(strategy = GenerationType.AUTO)
	//private Long id;
	/**
	 * 权限组名称
	 */	
	@Column(length = 20, unique = true,name="name")
	private String name;
	/**
	 * 权限组描述说明
	 */	
	@Column(length = 64,name="description")
	private String description;

	public RoleGroup() {
	}
	/**
	 * 权限组对应的权限
	 */	
//	@ManyToMany(fetch = FetchType.LAZY)
//	@JoinTable(name = "ST_ROLEGROUP_ROLE", joinColumns = { @JoinColumn(name = "rolegroup_id") }, inverseJoinColumns = @JoinColumn(name = "role_id"))
//	private List<Role> roles = new ArrayList<Role>();


	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getDescription() {
		return description;
	}

	/**
	 * {@inheritDoc}
	 */
	public boolean equals(Object o) {
		if (this == o) {
			return true;
		}
		if (!(o instanceof RoleGroup)) {
			return false;
		}

		final RoleGroup obj = (RoleGroup) o;

		return !(name != null ? !name.equals(obj.name) : obj.name != null);

	}

	/**
	 * {@inheritDoc}
	 */
	public int hashCode() {
		return (name != null ? name.hashCode() : 0);
	}

	public int compareTo(Object o) {
		return (equals(o) ? 0 : -1);
	}

}
